Skip to content

Conversation

@anonrig
Copy link
Member

@anonrig anonrig commented Aug 8, 2024

Fixes the implementation of Swap16, Swap32 and Swap64.

bool SwapBytes32(char *data, size_t nbytes) {
if (nbytes % sizeof(uint32_t) != 0) return false;

#if defined(_MSC_VER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am skeptical that this MS code is needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We can have SIMD support for this swap functions :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We can have SIMD support for this swap functions :-)

Absolutely, although a single instruction can reverse 8 bytes so it is already very fast!!!

@anonrig anonrig merged commit e435a29 into main Aug 8, 2024
@anonrig anonrig deleted the anonrig/fix-swap-bytes branch August 8, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants